home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-11-05 | 2.4 KB | 109 lines | [TEXT/MACA] |
- Two more idle DAs.
-
- Moire.da bounces two points (random speeds) and inscribes objects within the generated rectangles.
- '[' and ']' shorten and lengthen the queue.
- 'q' toggles speed quantization.
- '0' thru '9' set a speed limit for points ('0' means none).
- Other keys change shape:
- 'r' - rectangle (default for unassigned keys)
- 'o' - oval
- 'd' - diamond
- 't' - triangle
- 'p' - pentagram (for satanic users)
- 'h' - hourglass
- 'v' - a vee
- 'x' - an ex
- '/' & '\' - slanted lines
-
- Poly.da bounces up to ten points and connects the dots.
- '[' and ']' shorten and lengthen the queue.
- 'q' toggles speed quantization
- '0' - '9' set the # points in the polygon ('0' and '1' mean 10)
-
- The source consists of three files:
- idler.c - a common DA shell that may be used for writing other DAs.
- moire.c - drawing routines for moire.da
- poly.c - drawing routines for poly.da
-
- Produced using LightSpeed* C!
-
-
- SHAR_EOF
- sed 's/^X//' << 'SHAR_EOF' > Idler.c
- /*
- * shell routine for idle DAs
- */
- #include <hd20:lightspeed:mac:DeviceMgr.h>
- #include <hd20:lightspeed:mac:WindowMgr.h>
- #include <hd20:lightspeed:mac:EventMgr.h>
- #include <hd20:lightspeed:mac:MenuMgr.h>
-
- main(cp, dp, entry)
- cntrlParam *cp;
- DCtlPtr dp;
- int entry;
- {
- EventRecord *ep;
- static Rect screen;
- static Handle menuH;
- static WindowPtr windP;
- static Boolean active = false;
-
-
- if (!dp->dCtlStorage) {
- if (!entry)
- CloseDriver(dp->dCtlRefNum);
- return 0;
- }
- switch (entry) {
- case 0: /* open */
- dp->dCtlFlags |= dNeedLock | dNeedTime;
- dp->dCtlDelay = 0;
- dp->dCtlEMask = everyEvent;
-
- GetWMgrPort(&windP);
- screen = windP->portRect;
- windP = NewWindow(0L, &screen, "\p", true, noGrowDocProc, -1L, true, 0L);
- RectRgn(windP->visRgn, &screen);
- ((WindowPeek) windP)->windowKind = dp->dCtlRefNum;
-
- initIdle(&screen);
- break;
- case 2: /* control */
- SetPort(windP);
- switch (cp->csCode) {
- case accRun:
- if (active)
- runIdle(&screen);
- break;
- case accEvent:
- ep = (EventRecord *)*(long *)&cp->csParam;
- switch (ep->what) {
- case activateEvt:
- menuH = GetMenuBar();
- ClearMenuBar();
- PaintRect(&screen);
- PenMode(patXor);
- active = true;
- break;
- case keyDown:
- if (!active || keyIdle((int)(ep->message & charCodeMask)) >= 0)
- break;
- case mouseDown:
- CloseDriver(dp->dCtlRefNum);
- break;
- }
- break;
- }
- break;
-
- case 4: /* close */
- DisposeWindow(windP);
- SetMenuBar(menuH);
- DisposHandle(menuH);
- DrawMenuBar();
- break;
- }
- return 0;
- }
-